<!--歌曲列表-->
<template>
  <div>
    <ul>
      <router-link tag="li" :to="{
        path: '/PlayPage',
        query:{id:item.id,name:'12'}
        // name:'/PlayPage',
        // params:{id:item.id,name:'12'}

      }"
                   v-for="(item,index) in newMusicList " :key="item.id">
        <div v-if="(index + 1)<=3" v-show="isshow" :class="{'rank':true,'redRank':true}">{{ index + 1 }}</div>
        <div v-else v-show="isshow" :class="{'rank':true,'redRank':false}">{{ index + 1 }}</div>
        <div class="left">
          <p>{{ item.name }}
            <span v-if="item.song">{{ subtitle(item.song.alias[0]) }}</span>
          </p>
          <span class="sq"></span>
          <span v-if="item.song"> {{ author(item.song.artists) }} - {{ item.song.album.name }}</span>
          <span v-else> {{ author(item.ar) }} - {{ item.al.name }}</span>
        </div>
        <div class="right"></div>
        <!--        </router-link>-->
      </router-link>
    </ul>
  </div>
</template>

<script>


// import {getDetailSong} from "@/api/index-api";

export default {
  name: "NewMusic",
  props: {
    newMusicList: Array,
    isshow: Boolean
  },
  data() {
    return {
      // PlayPagelist: null
    }
  },
  created() {
    // console.log(this.newMusicList)
    // getDetailSong(3778678).then((res) => {
    //   console.log(res)
    //   if (res.code === 200) {
    //     this.list = res.result
    //   }
    // })
  },
  methods: {
    author(author) {
      let authotName = []
      author.forEach(item => {
        authotName.push(item.name)
      })
      return authotName.join(" / ")
    },
    subtitle(name) {
      if (name === undefined) {
        return ""
      } else {
        return "(" + name + ")"
      }
    },


  }
}
</script>

<style scoped lang="less">
a {
  color: #000;
}

li {
  list-style: none;
  margin-left: 10px;
  font-size: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ddd;
  position: relative;


  .right {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 30px;
    height: 30px;
    background-image: url("../../public/img/index_icon_2x.png");
    background-size: 160px 100px;
    background-position: -16px 0px;
  }

  .rank {
    float: left;
    width: 40px;
    height: 40px;
    font-size: 18px;
    text-align: center;
    line-height: 40px;
  }

  .redRank {
    color: red;
  }

  .left {
    width: 100%;


    p {
      font-size: 16px;
      margin: 10px 0;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      padding-right: 50px;

      span {
        color: #999;
      }
    }

    .sq {
      display: inline-block;
      width: 12px;
      height: 10px;
      background-image: url("../../public/img/index_icon_2x.png");
      background-size: 160px 100px;
      position: relative;
      top: 2px;
    }
  }

}


</style>